package example.springboot.controller;


import example.springboot.mapper.userMapper;
import example.springboot.model.Question;
import example.springboot.model.t_user;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class questionDisplayController {
    @Autowired
    example.springboot.mapper.questionMapper questionMapper;
    @Autowired
    userMapper userMapper;

    /**
     * 点击列表问题跳转显示编辑
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("/question/{id}")
    public String byIdGetQuestion(@PathVariable("id")String id,
                                  Model model){
        Question question = questionMapper.byIdFind(id);
        t_user user = userMapper.byAccountidFind(question.getCreator());
        question.setUser(user);
        model.addAttribute("question",question);
        return "question";
    }

}
